package com.github.chirspan.xaas.cfg.web.rest;


import com.github.chirspan.xaas.cfg.model.CfgApiLog;
import com.github.chirspan.xaas.api.BaseCRUDRestController;
import com.github.chirspan.xaas.core.exception.BizException;
import com.github.chirspan.xaas.core.rest.RestResult;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.rmi.RemoteException;


/**
 * @Author: chenpan
 * @Date: 2021-04-07 18:24:52
 * @Description: 系统操作日志 REST API
 */
@RestController
@RequestMapping("apiLog")
public class CfgApiLogController extends BaseCRUDRestController<CfgApiLog> {

    @PostMapping("/event")
    public RestResult addApiLog(@ApiParam("新增实体") @RequestBody @Validated CfgApiLog m, BindingResult result) throws RemoteException, BindException {
        try {
            baseService.add(m);
            return RestResult.OK(m.getId(), "新增成功");
        } catch (Exception e) {
            throw new BizException("新增失败:" + e.getMessage());
        }
    }
}